<?php

/**
 * photo actions.
 *
 * @package    sfwixet
 * @subpackage photo
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class photoCommentsComponents extends sfComponents
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
  	//$photo = Photo::secureLoad($request->getParameter("id"),$this->getUser()->getId());
  	try{
  		$photo = Doctrine::getTable("Photo")->find($request->getParameter("id"));

  		$this->comments = $photo->getComments(0,10);
  		$this->pageCount = ceil($photo->getTotalComments()/10);
  		//Remove notifications
  		Doctrine::getTable("PhotoCommentNotification")->findByDql("photo_id = ? AND user_id = ?",array($photo->getPhotoId(),$this->getUser()->getId()))->delete();
  	}
  	catch(AclException $e)
  	{
  		$this->comments = array();
  		$this->pageCount = 0;
  	}
  }
  
  public function executeTitle(sfWebRequest $request)
  {
  	$this->title=__("Comments");
  }
}
